package 笔试.顺丰;

import javax.annotation.Resources;
import java.time.temporal.Temporal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/6-20:03
 * @version:1.0
 * @function:
 */
public class Main02 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int res = 0;
        while (n>0){
            if (fun(scanner.nextInt())) res++;
            n--;
        }
        System.out.println(res);
    }

    private static boolean fun(Integer num) {
        String str = String.valueOf(num);
        int len = str.length();
        int temp = create(len);
        if(num<0||temp<10) return false;
        if (fun2(num,len)||num-temp==0)return true;
        else if (num-temp>0){
            num -= temp;
            return fun(num);
        }else {
            temp = create(len-1);
            num -= temp;
            return fun(num);
        }
    }

    private static boolean fun2(Integer num, int len) {
        while (len>=2){
            int temp = create(len);
            if (num%temp==0)
                return true;
            len--;
        }
        return false;
    }

    private static int create(int i) {
        StringBuilder str = new StringBuilder();
        for (int j = 0; j < i; j++) {
            str.append(1);
        }
        return Integer.parseInt(str.toString());
    }
}
